<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./../template/WorkspaceTemplate.xhtml">

    <ui:define name="top">

    </ui:define>

    <ui:define name="left">
    </ui:define>

    <ui:define name="right">

    </ui:define>

    <ui:define name="content">
        <style>
            .ui-state-highlight.ui-selected {
                color: blueviolet;
            }
        </style>
        <h2>View Credit Account</h2>

        <h:form id="creditAccountForm" style="font-size: 85%">
            <p:panel id="panel1">
                <p:messages  />
                <br/>
                <h:outputText value="Basic Information" style="font-weight: bold; font-size: 110%"/>
                <p:separator/> 
                <br/>
                <h:panelGrid columns="8" cellpadding="10" style="width: 100%">
                    <h:outputLabel style="font-weight: bold" value="Client ID: "/>
                    <h:outputText id="clientId" style="font-weight: bold" value="#{caManagerBean.ca.customer.clientId}"/>
                    <h:outputLabel value=""/>
                    <h:outputLabel value=""/>
                    <h:outputLabel value=""/>
                    <h:outputLabel value=""/>
                    <h:outputLabel style="font-weight: bold" value="Date Created: "/>
                    <h:outputText style="font-weight: bold" value="#{caManagerBean.ca.creditAccountDate}">
                        <f:convertDateTime pattern="MMMM dd, yyyy"/>
                    </h:outputText>

                    <h:outputLabel style="font-weight: bold" value="Company Name: "/>
                    <h:outputText id="companyName" style="font-weight: bold" value="#{caManagerBean.ca.customer.companyName}"/>
                    <h:outputLabel value=""/>
                    <h:outputLabel value=""/>
                    <h:outputLabel value=""/>
                    <h:outputLabel value=""/>
                    <h:outputLabel style="font-weight: bold" value="Status: "/>
                    <h:selectOneRadio id="credit" value="#{caManagerBean.ca.isDefault}" disabled="true">  
                        <f:selectItem itemLabel="Active" itemValue="false" />
                        <f:selectItem itemLabel="Default" itemValue="true" />
                    </h:selectOneRadio>
                </h:panelGrid>

                <br/>
                <br/>
                <br/>

                <h:outputText value="Credit Account Settings" style="font-weight: bold; font-size: 110%"/>
                <p:separator/> 
                <br/>
                <h:panelGrid columns="4" style="width: 100%" cellpadding="10">
                    <h:outputLabel style="font-weight: bold" value="Assign Credit Group: "/>
                    <h:selectOneMenu value="#{caManagerBean.ca.creditGroup.id}" label="Credit" disabled="true">  
                        <f:selectItem itemLabel="-- Select One --" itemValue="-1" />  
                        <f:selectItems value="#{caManagerBean.allCgs}" var="cg" itemLabel="#{cg.creditGroupTitle}" itemValue="#{cg.id}"/>
                        <p:ajax update="creditAccountForm:creditGroupDetails" listener="#{caManagerBean.setCreditGroup}"/>
                    </h:selectOneMenu>
                    <h:outputLabel value=""/>
                    <h:panelGrid id="creditGroupDetails" columns="1" style="border-style: solid; border-color: #AFAFAF; padding: 10px">
                        <h:outputText value="Credit Group Details" style="font-weight: bold; font-size: 110%"/>
                        <p:separator/> 
                        <br/>
                        <h:panelGrid columns="2" cellpadding="10">
                            <h:outputLabel style="font-weight: bold" value="Extension Day: "/>
                            <h:outputText style="font-weight: bold" value="#{caManagerBean.ca.creditGroup.extensionDays} days"/>
                            <h:outputLabel style="font-weight: bold" value="Credit Limit: "/>
                            <h:outputText style="font-weight: bold" value="#{caManagerBean.ca.creditGroup.creditLimitForDs}" rendered="#{caManagerBean.renderDSCreditAmount()}">
                                <f:convertNumber type="currency"/>
                            </h:outputText>
                            <h:outputText style="font-weight: bold" value="#{caManagerBean.ca.creditGroup.creditLimitForWs}" rendered="#{caManagerBean.renderWSCreditAmount()}">
                                <f:convertNumber type="currency"/>
                            </h:outputText>
                            <h:outputText style="font-weight: bold" value="Not selected" rendered="#{!caManagerBean.renderWSCreditAmount() &amp;&amp; !caManagerBean.renderDSCreditAmount()}"/>
                            <h:outputLabel style="font-weight: bold" value="Credit Used: "/>
                            <h:outputText style="font-weight: bold" value="#{caManagerBean.ca.creditUsed}">
                                <f:convertNumber type="currency"/>
                            </h:outputText>
                            <h:outputLabel style="font-weight: bold" value="Current Balance: "/>
                            <h:outputText style="font-weight: bold" value="#{caManagerBean.ca.creditBalance}">
                                <f:convertNumber type="currency"/>
                            </h:outputText>
                        </h:panelGrid>
                    </h:panelGrid>
                </h:panelGrid>

                <br/>
                <br/>
                <br/>

                <h:outputText value="Currency Settings" style="font-weight: bold; font-size: 110%"/>
                <p:separator/> 
                <br/>
                <h:panelGrid columns="2" style="width: 100%" cellpadding="10">
                    <h:outputLabel style="font-weight: bold" value="Currency: "/>
                    <h:selectOneRadio value="#{caManagerBean.ca.currency}" disabled="true">
                        <f:selectItem itemLabel="SGD" itemValue="true" />
                        <f:selectItem itemLabel="USD" itemValue="false" />
                    </h:selectOneRadio>
                </h:panelGrid>

            </p:panel>

            <br/>
            <br/>
            <br/>
            <div align="right">
                <p:commandButton value="Back" image="ui-icon ui-icon-arrowreturnthick-1-w" action="viewCreditAccount?faces-redirect=true"/>
                <p:commandButton value="Update Credit Account" image="ui-icon ui-icon-pencil" action="#{caManagerBean.updateCreditAccount()}" update="creditAccountForm"/>
            </div>
            <br/>
            <br/>
            <br/>
        </h:form>

    </ui:define>

    <ui:define name="bottom">

    </ui:define>

</ui:composition>
